*----------------------------------------------------
* Replication materials for "Party Cues in the News: 
* Democratic Elites, Republican Backlash and 
* the Dynamics of Climate Skepticism"

* British Journal of Political Science
*----------------------------------------------------

/* Authors:

Eric Merkley
Munk School of Global Affairs & Public Policy
University of Toronto
Email: eric.merkley@utoronto.ca 
ORCID: 0000-0001-7647-9650
www.ericmerkley.com

Dominik Andrzej Stecula
Annenberg Public Policy Center
University of Pennsylvania 
& Simon Fraser University
Email: dominik.stecula@appc.upenn.edu
ORCID: 0000-0001-6724-7559
www.stecula.com

*/

*----------------------------------------------------
* Program Setup
*----------------------------------------------------
version 15              																		// Version number for backward compatibility
clear all               																		// Start with a clean slate
set more off            																		// Disable partitioned output
macro drop _all         																		// clear all macros

* We use a plotplain scheme for figures

********************************************************************************
* Figure 1 - Mood
********************************************************************************

* Panel A --- USE ANNUAL DATA

twoway (line skeptic_std year if year>1985 & year<2015, lstyle(p1) lwidth(thick)) ///
	, scheme(plotplain) ytitle("Annual skepticism", size(medium) margin(small)) ylab(-3(1)3, labs(medium) ) xlab(1986(4)2014, labs(medium)) ///
	xlabel(, angle(horizontal) labs(medium)) xtitle("") title("", size(medlarge) margin(small)) ///
	legend(off) text(3 1986 "A", placement(e) size(medlarge))
graph save 1A.gph, replace

* Panel B --- USE QUARTERLY DATA

twoway (line skeptic_std qt if qt>163 & qt<219, lstyle(p1) lwidth(thick)) ///
	, scheme(plotplain) ytitle("Quarterly skepticism", size(medium) margin(small)) ylab(-3(1)3, labs(medium) ) xlab(164(14)222, labs(medium)) ///
	xlabel(, angle(horizontal) labs(medium)) xtitle("") title("", size(medlarge) margin(small)) ///
	legend(off) text(3 164 "B", placement(e) size(medlarge))
graph save 1B.gph, replace

* Panel C --- USE QUARTERLY DATA

twoway (line pccti_std_rev qt if qt>163 & qt<219, lc(black) lwidth(thick)) ///
	, scheme(plotplain) ytitle("Republican skepticism", size(medium) margin(small)) ylab(-3(1)3, labs(medium) ) xlab(164(14)222, labs(medium)) ///
	xlabel(, angle(horizontal) labs(medium)) xtitle("") title("", size(medlarge) margin(small)) ///
	legend(off) text(3 164 "C", placement(e) size(medlarge)) 

graph save 1C.gph, replace

* Assemble into a single figure

graph combine 1A.gph 1B.gph 1C.gph, row(1) scheme(plotplain) ysize(4) xsize(8) 
graph export figure1.png, width(2000) replace


********************************************************************************
* Figure 2 - Content analysis 
********************************************************************************

* Panel A --- USE QUARTERLY DATA

twoway (lowess gop_prop qt if qt>163 & qt<219, bwidth(0.05) lstyle(p1) lcolor(black) lwidth(thick)) ///
	(lowess dem_prop qt if qt>163 & qt<219, bwidth(0.05) lstyle(p1) lcolor(gs10) lwidth(thick)) ///
	, scheme(plotplain) ytitle("% of news coverage", size(medium) margin(small)) ylab(0(10)60, labs(medium)) ///
	xlab(164(14)222, labs(medium)) xlabel(, angle(horizontal) labs(medium)) xtitle("") title("", size(medlarge) margin(small)) ///
	legend(row(1) keygap(.8) symxsize(5) symysize(.8) size(medlarge) rowgap(.1) lab(1 "Republicans") ///
	lab(2 "Democrats") position(1) ring(0) region(lstyle(none) fcolor(none)))  text(60 164 "A", placement(e) size(medlarge)) 
graph save 2A.gph, replace

* Panel B --- USE QUARTERLY DATA
	
twoway (lowess uncert_prop qt if qt>163 & qt<219, bwidth(0.05) lstyle(p1) lwidth(thick)) ///
	, scheme(plotplain) ytitle("Uncertainty framing", size(medium) margin(small)) ylab(0(10)60, labs(medium) ) xlab(164(14)222, labs(medium)) ///
	xlabel(, angle(horizontal) labs(medium)) xtitle("") title("", size(medlarge) margin(small)) ///
	legend(off) text(60 164 "B", placement(e) size(medlarge))
graph save 2B.gph, replace

* Panel C --- USE QUARTERLY DATA

twoway (lowess econcost_prop qt if qt>163 & qt<219, bwidth(0.05) lstyle(p1) lwidth(thick)) ///
	, scheme(plotplain) ytitle("Economic cost framing", size(medium) margin(small)) ylab(0(10)60, labs(medium) ) xlab(164(14)222, labs(medium)) ///
	xlabel(, angle(horizontal) labs(medium)) xtitle("") title("", size(medlarge) margin(small)) ///
	legend(off) text(60 164 "C", placement(e) size(medlarge))
graph save 2C.gph, replace

* Panel D --- USE QUARTERLY DATA

twoway (lowess volume qt if qt>163 & qt<219, bwidth(0.05) lstyle(p1) lcolor(black) lp(solid) lwidth(thick)) ///
	, scheme(plotplain) ytitle("Volume of news coverage", size(medium) margin(small)) ylab(0(50)300, labs(medium)) ///
	xlab(164(14)222, labs(medium)) xlabel(, angle(horizontal) labs(medium)) xtitle("") title("", size(medlarge) margin(small)) ///
	legend(off) text(300 164 "D", placement(e) size(medlarge))
graph save 2D.gph, replace

* Assemble into a single figure

graph combine 2A.gph 2B.gph 2C.gph 2D.gph, col(2) scheme(plotplain) ysize(4) xsize(6) 
graph export figure2.png, width(2000) replace


********************************************************************************
* Tables 1 & 2 - Regression models
********************************************************************************

* Vector Autoregressions --- USE QUARTERLY DATA

tab quarter, gen(qt)

qui: var skeptic_ns dem_prop, ex(L.climate L.unemp L.crude qt2 qt3 qt4) lag(1)
vargranger

qui: var skeptic_ns gop_prop, ex(L.climate L.unemp L.crude qt2 qt3 qt4) lag(1)
vargranger

qui: var pccti dem_prop, ex(L.climate L.unemp L.crude qt2 qt3 qt4) lag(1/2)
vargranger

qui: var pccti gop_prop, ex(L.climate L.unemp L.crude qt2 qt3 qt4) lag(1) 
vargranger

* Contemporaneous Models --- USE QUARTERLY DATA

qui: reg skeptic_std L.skeptic_std dem_prop gop_prop uncert_prop econcost_prop volume climate crude unemp i.quarter, robust beta
eststo Quarterly_A

qui: reg pccti_std_rev L.pccti_std_rev dem_prop gop_prop uncert_prop econcost_prop volume climate crude unemp i.quarter, robust beta
eststo GOP_A

esttab Quarterly_A GOP_A, se(2) b(2) nogap r2(2) star( * 0.1 ** 0.05 *** 0.01)

* Contemporaneous Models --- USE ANNUAL DATA

qui: reg skeptic_std L.skeptic_std dem_prop gop_prop uncert_prop econcost_prop volume climate crude unemp, robust beta
eststo Annual_A

esttab Annual_A, se(2) b(2) nogap r2(2) star( * 0.1 ** 0.05 *** 0.01)


********************************************************************************
* Figure 3 - Experiment
********************************************************************************

* USE EXPERIMENT DATA

reg skeptic i.treat##c.pid i.treat##c.polint i.treat##c.trust if screen>0

qui: reg skeptic i.treat2##c.pid i.treat3##c.pid i.treat4##c.pid i.treat5##c.pid i.treat6##c.pid ///
	i.treat2##c.polint i.treat3##c.polint i.treat4##c.polint i.treat5##c.polint i.treat6##c.polint ///
	i.treat2##c.trust i.treat3##c.trust i.treat4##c.trust i.treat5##c.trust i.treat6##c.trust if screen>0

qui: margins, dydx(treat2) at(pid=(1(1)7))
marginsplot, yline(0, lcolor(gs10) lp(dash) lwidth(med)) recast(line) plotop(lw(thick)) recastci(rarea) ci1op(lc(bg) fc(gs10)) l(90) scheme(plotplain)  ylabel(-0.15(0.15)0.15) xlabel(, angle(45)) xtitle("") ///
	title("", size(medium)) ciop(lpattern(solid) lwidth(thick) lc(black)) ytitle("") text(0.15 1 "A: Democratic Cue", placement(e) size(medium)) name(A, replace)
	
qui: margins, dydx(treat3) at(pid=(1(1)7))
marginsplot, yline(0, lcolor(gs10) lp(dash) lwidth(med)) recast(line) plotop(lw(thick)) recastci(rarea) ci1op(lc(bg) fc(gs10)) l(90) scheme(plotplain)  ylabel(-0.15(0.15)0.15) xlabel(, angle(45)) xtitle("") ///
	title("", size(medium)) ciop(lpattern(solid) lwidth(thick) lc(black)) ytitle("") text(0.15 1 "B: Opposing GOP Cue", placement(e) size(medium)) name(B, replace)
	
qui: margins, dydx(treat4) at(pid=(1(1)7))
marginsplot, yline(0, lcolor(gs10) lp(dash) lwidth(med)) recast(line) plotop(lw(thick)) recastci(rarea) ci1op(lc(bg) fc(gs10)) l(90) scheme(plotplain)  ylabel(-0.15(0.15)0.15) xlabel(, angle(45)) xtitle("") ///
	title("", size(medium)) ciop(lpattern(solid) lwidth(thick) lc(black)) ytitle("") text(0.15 1 "C: Polarized Cues", placement(e) size(medium)) name(C, replace)
	
qui: margins, dydx(treat5) at(pid=(1(1)7))
marginsplot, yline(0, lcolor(gs10) lp(dash) lwidth(med)) recast(line) plotop(lw(thick)) recastci(rarea) ci1op(lc(bg) fc(gs10)) l(90) scheme(plotplain)  ylabel(-0.15(0.15)0.15) xlabel(, angle(45)) xtitle("") ///
	title("", size(medium)) ciop(lpattern(solid) lwidth(thick) lc(black)) ytitle("") text(0.15 1 "D: Supporting GOP Cue", placement(e) size(medium)) name(D, replace)
	
qui: margins, dydx(treat6) at(pid=(1(1)7))
marginsplot, yline(0, lcolor(gs10) lp(dash) lwidth(med)) recast(line) plotop(lw(thick)) recastci(rarea) ci1op(lc(bg) fc(gs10)) l(90) scheme(plotplain)  ylabel(-0.15(0.15)0.15) xlabel(, angle(45)) xtitle("") ///
	title("", size(medium)) ciop(lpattern(solid) lwidth(thick) lc(black)) ytitle("") text(0.15 1 "E: Consensus Cues", placement(e) size(medium)) name(E, replace)

graph combine A B D E, row(2) ycommon ysize(4) xsize(4) imargin(vsmall) graphr(margin(zero) lcolor(white)) name(left, replace)
graph combine left C, col(2) ysize(4) xsize(8) iscale(1.2) graphr(c(white) lcolor(white)) scheme(plotplain)
graph export figure3.png, width(2000) replace






















